//
//  CXSmallCollectionViewCell.m
//  Delicious
//
//  Created by dllo on 15/11/25.
//  Copyright © 2015年 doll. All rights reserved.
//

#import "CXSmallCollectionViewCell.h"
#import "CXRecommendCollectionModel.h"
#import "UIImageView+WebCache.h"

@interface CXSmallCollectionViewCell ()

@property (nonatomic, retain) UIImageView *sanImg;
@property (nonatomic, retain) UIView *blackView;
@property (nonatomic , assign)BOOL isclear;

@end

@implementation CXSmallCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        
        //轮播图图片
        self.sanImg = [[UIImageView alloc] init];
        [self.sanImg setBackgroundColor:[UIColor yellowColor]];
        [self.contentView addSubview:self.sanImg];
        [self.sanImg setUserInteractionEnabled:YES];
        
        
        self.blackView = [[UIView alloc] init];
        [self.blackView setBackgroundColor:[UIColor blackColor]];
        [self.sanImg addSubview:self.blackView];
        self.blackView.alpha = 0.5;
        
        self.blackView.userInteractionEnabled = YES;
        
    }
    return self;
}


- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    [super applyLayoutAttributes:layoutAttributes];
    self.sanImg.frame = CGRectMake(0, 2 * SCALE, 84 * SCALE, 84 * SCALE);
    self.blackView.frame = CGRectMake(0, 0, 84 * SCALE, 84 * SCALE);
}

- (void)setModel_recommend:(CXRecommendCollectionModel *)model_recommend
{
    if (_model_recommend != model_recommend)
    {
        _model_recommend = model_recommend;
    }
    [self.sanImg sd_setImageWithURL:[NSURL URLWithString:self.model_recommend.titlepic_m] placeholderImage:[UIImage imageNamed:@"jiazaitu"]];
    
    if (self.model_recommend.isClear)
    {
        _blackView.alpha = 0;
    }else {
        _blackView.alpha = 0.5;
    }
}



@end
